package com.xingkeduo.business.operation.controller.cms;

import com.xingkeduo.business.operation.domain.ManagerDomain;
import com.xingkeduo.pojo.dto.Manager.ManagerPermsDTO;
import com.xingkeduo.pojo.json.ManagerJson;
import com.xingkeduo.pojo.query.ManagerQuery;
import com.xingkeduo.pojo.table.ManagerTable;
import com.xingkeduo.util.pojo.base.BaseController;
import com.xingkeduo.util.pojo.domain.Page;
import com.xingkeduo.util.tool.ReturnUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.xingkeduo.tool.OperaConstants.CMS_URL_PREFIX;

/**
 * 文件概述
 *
 * @author wangxilong <wangxilong@xingkeduo.com>
 * @version id:v0.1 19-1-25 上午10:42
 * @package BeautyOS
 * @copyright Copyright (c) XKD 2019
 */
@RestController
@RequestMapping(CMS_URL_PREFIX + "/cmanager")
public class CManagerController extends BaseController {

    @Autowired
    private ManagerDomain managerDomain;

    //查询列表
    @RequestMapping(value = "/lists", method = RequestMethod.GET)
    @ResponseBody
    public String doGetLists(ManagerQuery managerQuery) {
        returnUtil = new ReturnUtil();
        try {
//            ManagerQuery managerVo = JSON.parseObject(urlParam,ManagerQuery.class);
            ManagerQuery managerVo = managerQuery;
            Page<ManagerTable> managerList= managerDomain.getManagerPageList(managerQuery);
            return returnUtil.getSuccess(ManagerJson.toJsonPage(managerList));
        } catch (Throwable throwable) {
            return dealException(throwable, returnUtil);
        }
    }

    //查询列表
    @RequestMapping(value = "/isperms", method = RequestMethod.GET)
    @ResponseBody
    public String doGetIsPerms(ManagerPermsDTO managerPermsDTO) {
        returnUtil = new ReturnUtil();
        try {
            Boolean aBoolean= managerDomain.getManagerIsPerms(managerPermsDTO);
            return returnUtil.getSuccess();
        } catch (Throwable throwable) {
            return dealException(throwable, returnUtil);
        }
    }
}
